Skip to content

Conversation

@jycor
Copy link
Contributor

@jycor jycor commented Oct 24, 2024

This PR optimized queries like:

select distinct i from t order by i;

When there are many duplicate values in column i, it is much more efficient to eliminate duplicates first, then sort the results.

There are somewhat unrelated optimizations left as TODOs.

Optimize query: dolthub/dolt#8488

@jycor jycor changed the title push distinct below sort push Distinct nodes below Sort nodes Oct 24, 2024
}

func (f *factory) buildDistinct(child sql.Node) sql.Node {
if proj, isProj := child.(*plan.Project); isProj {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the one thing i would add is a quick // from => to docstring to make the tranform clearer

Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@jycor jycor merged commit afe6195 into main Oct 24, 2024
8 checks passed
@jycor jycor deleted the james/distinct branch October 24, 2024 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants